package org.dizem.groupon.service.impl;

import org.dizem.groupon.dao.CategoryDAO;
import org.dizem.groupon.model.domain.CategoryEntity;
import org.dizem.groupon.service.CategoryService;

import java.util.List;

/**
 * User: dizem@126.com
 * Time: 11-6-28 下午1:45
 */
public class CategoryServiceImpl implements CategoryService {
	private CategoryDAO categoryDAO;

	public CategoryDAO getCategoryDAO() {
		return categoryDAO;
	}

	public void setCategoryDAO(CategoryDAO categoryDAO) {
		this.categoryDAO = categoryDAO;
	}

	public void save(CategoryEntity object) {
		categoryDAO.save(object);
	}

	public void delete(CategoryEntity object) {
		categoryDAO.delete(object);
	}

	public void update(CategoryEntity object) {
		CategoryEntity category = categoryDAO.getByName(object.getName());
		category.setDescription(object.getDescription());
		categoryDAO.update(category);
	}

	public CategoryEntity getById(int id) {
		return categoryDAO.getById(id);
	}

	public List<CategoryEntity> loadAll() {
		return categoryDAO.loadAll();
	}

	public List<CategoryEntity> load(int firstResult, int maxResult) {
		return categoryDAO.load(firstResult, maxResult);
	}

	public int getCount() {
		return categoryDAO.getCount();
	}
}
